# !/usr/usuari/des python
#  -*- coding: utf-8 -*-
"""
@Author        : itgnay
@Time          : 2023/2/6 20:49
@FileName      : 矩形计数.py
@LastEditors   : None
@Editors       : PyCharm
"""
"""
题目描述：
一个 N×M 的方格矩阵，每一个方格中包含一个字符 O 或者字符 X。
要求矩阵中不存在连续一行 3 个 X 或者连续一列 3 个 X。
问这样的矩阵一共有多少种？

输入描述：
输入一行包含两个整数 N,M (1 ≤ N,M ≤ 5)

"""
import os
import sys

# 请在此输入您的代码
N, M = [int(i) for i in input().split()]
stateCrowd = []
for i in range(1 << N):
    k = 0
    for j in range(N):
        if k == 3:
            break
        elif (i >> j) % 2:
            k += 1
        else:
            k = 0
    if k < 3:
        stateCrowd.append(i)
"""初始化"""
dp = [[[0] * (1 << N) for _ in range(1 << N)] for __ in range(M)]
for i in stateCrowd:
    dp[0][i][0] = 1

for n in range(M - 1):
    for i in stateCrowd:
        for j in stateCrowd:
            for p in stateCrowd:
                if i & j & p == 0:
                    dp[n + 1][i][j] += dp[n][j][p]

print(sum([sum(state) for state in dp[-1]]))
